{% extends "base.html" %}

{% block title %}执行指令 - 协同调度信息系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-4">
        <!-- 指令信息 -->
        <div class="card">
            <div class="card-header">
                <h6 class="mb-0">
                    <i class="fas fa-bullhorn"></i> 指令信息
                </h6>
            </div>
            <div class="card-body">
                <h6>{{ order.target }}</h6>
                <p><strong>指令类型:</strong> 
                    {% if order.order_type == 'reconnaissance' %}侦察指令
                    {% elif order.order_type == 'analysis' %}分析指令
                    {% elif order.order_type == 'execution' %}执行指令
                    {% endif %}
                </p>
                <p><strong>优先级:</strong> 
                    <span class="priority-badge priority-{{ order.priority }}">
                        {% if order.priority == 'low' %}低
                        {% elif order.priority == 'medium' %}中
                        {% elif order.priority == 'high' %}高
                        {% elif order.priority == 'critical' %}紧急
                        {% endif %}
                    </span>
                </p>
                <p><strong>下达时间:</strong> {{ order.created_at.strftime('%Y-%m-%d %H:%M') }}</p>
            </div>
        </div>

        <!-- 指令目标 -->
        <div class="card mt-3">
            <div class="card-header">
                <h6 class="mb-0">
                    <i class="fas fa-target"></i> 指令目标
                </h6>
            </div>
            <div class="card-body">
                <div class="bg-light p-3 rounded">
                    <pre style="white-space: pre-wrap; margin: 0; font-size: 0.9rem;">{{ order.objective }}</pre>
                </div>
            </div>
        </div>

        <!-- 具体指令 -->
        <div class="card mt-3">
            <div class="card-header">
                <h6 class="mb-0">
                    <i class="fas fa-list"></i> 具体指令
                </h6>
            </div>
            <div class="card-body">
                <div class="bg-light p-3 rounded" style="max-height: 300px; overflow-y: auto;">
                    <pre style="white-space: pre-wrap; margin: 0; font-size: 0.9rem;">{{ order.instructions }}</pre>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-8">
        <!-- 执行结果表单 -->
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">
                    <i class="fas fa-cogs"></i> 执行结果
                </h5>
            </div>
            <div class="card-body">
                <form method="POST">
                    {{ form.hidden_tag() }}
                    
                    <div class="mb-3">
                        {{ form.result_type.label(class="form-label") }}
                        {{ form.result_type(class="form-select") }}
                        {% if form.result_type.errors %}
                            <div class="text-danger">
                                {% for error in form.result_type.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                        <div class="form-text">
                            <i class="fas fa-info-circle"></i>
                            请如实选择执行结果类型
                        </div>
                    </div>

                    <div class="mb-3">
                        {{ form.description.label(class="form-label") }}
                        {{ form.description(class="form-control", rows="6", placeholder="请详细描述执行过程和结果...") }}
                        {% if form.description.errors %}
                            <div class="text-danger">
                                {% for error in form.description.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                        <div class="form-text">
                            <i class="fas fa-info-circle"></i>
                            请详细描述执行过程、遇到的问题、采取的措施和最终结果
                        </div>
                    </div>

                    <div class="mb-3">
                        {{ form.evidence.label(class="form-label") }}
                        {{ form.evidence(class="form-control", rows="4", placeholder="请提供执行证据，如截图、日志、文件等...") }}
                        {% if form.evidence.errors %}
                            <div class="text-danger">
                                {% for error in form.evidence.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                        <div class="form-text">
                            <i class="fas fa-info-circle"></i>
                            提供执行证据，如截图、日志文件、配置文件等（可选）
                        </div>
                    </div>

                    <div class="mb-3">
                        {{ form.impact_assessment.label(class="form-label") }}
                        {{ form.impact_assessment(class="form-control", rows="4", placeholder="请评估执行结果的影响...") }}
                        {% if form.impact_assessment.errors %}
                            <div class="text-danger">
                                {% for error in form.impact_assessment.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                        <div class="form-text">
                            <i class="fas fa-info-circle"></i>
                            评估执行结果对目标系统或环境的影响（可选）
                        </div>
                    </div>

                    <div class="mb-3">
                        {{ form.lessons_learned.label(class="form-label") }}
                        {{ form.lessons_learned(class="form-control", rows="3", placeholder="请总结执行过程中的经验教训...") }}
                        {% if form.lessons_learned.errors %}
                            <div class="text-danger">
                                {% for error in form.lessons_learned.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                        <div class="form-text">
                            <i class="fas fa-info-circle"></i>
                            总结执行过程中的经验教训和改进建议（可选）
                        </div>
                    </div>

                    <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                        <a href="{{ url_for('executor_dashboard') }}" class="btn btn-secondary me-md-2">
                            <i class="fas fa-arrow-left"></i> 返回
                        </a>
                        {{ form.submit(class="btn btn-primary") }}
                    </div>
                </form>
            </div>
        </div>

        <!-- 执行指导 -->
        <div class="card mt-4">
            <div class="card-header">
                <h6 class="mb-0">
                    <i class="fas fa-lightbulb"></i> 执行指导
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <h6><i class="fas fa-check-circle text-success"></i> 执行成功要点:</h6>
                        <ul class="list-unstyled small">
                            <li><i class="fas fa-arrow-right text-primary"></i> 严格按照指令要求执行</li>
                            <li><i class="fas fa-arrow-right text-primary"></i> 详细记录执行过程</li>
                            <li><i class="fas fa-arrow-right text-primary"></i> 提供充分的执行证据</li>
                            <li><i class="fas fa-arrow-right text-primary"></i> 评估执行结果的影响</li>
                        </ul>
                    </div>
                    <div class="col-md-6">
                        <h6><i class="fas fa-exclamation-triangle text-warning"></i> 注意事项:</h6>
                        <ul class="list-unstyled small">
                            <li><i class="fas fa-arrow-right text-warning"></i> 确保操作的安全性和合规性</li>
                            <li><i class="fas fa-arrow-right text-warning"></i> 遇到问题及时沟通反馈</li>
                            <li><i class="fas fa-arrow-right text-warning"></i> 保护敏感信息的安全</li>
                            <li><i class="fas fa-arrow-right text-warning"></i> 如实报告执行结果</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <!-- 执行结果类型说明 -->
        <div class="card mt-4">
            <div class="card-header">
                <h6 class="mb-0">
                    <i class="fas fa-info-circle"></i> 执行结果类型说明
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-4">
                        <div class="text-center">
                            <i class="fas fa-check-circle fa-2x text-success mb-2"></i>
                            <h6>执行成功</h6>
                            <small class="text-muted">
                                完全按照指令要求完成，达到预期目标
                            </small>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="text-center">
                            <i class="fas fa-exclamation-triangle fa-2x text-warning mb-2"></i>
                            <h6>部分成功</h6>
                            <small class="text-muted">
                                部分完成指令要求，存在一些限制或问题
                            </small>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="text-center">
                            <i class="fas fa-times-circle fa-2x text-danger mb-2"></i>
                            <h6>执行失败</h6>
                            <small class="text-muted">
                                未能完成指令要求，需要重新制定方案
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
